package com.bjpowernode.boss.mvc.service.Impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bjpowernode.boss.dao.entity.PayWay;
import com.bjpowernode.boss.dao.mapper.PayWayMapper;
import com.bjpowernode.boss.mvc.service.PayWayService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class PayWayServiceImpl implements PayWayService {

    @Resource
    private PayWayMapper payWayMapper;

    @Override
    public IPage<PayWay> pageList(Integer pageNo, Integer pageSize, String productCode) {
        QueryWrapper<PayWay> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("pay_product_code", "way_code", "type_code");
        if (StrUtil.isNotBlank(productCode)) {
            wrapper.eq("pay_product_code", productCode.trim());
        }
        return payWayMapper.selectPage(Page.of(pageNo, pageSize), wrapper);
    }
}
